﻿#ifndef _H_264SOURCE_H_INCLUDE_
#define _H_264SOURCE_H_INCLUDE_

#include "../../common/singleton.h"
#include "../../common/NedAllocatorImpl.h"
#include "rtsp_common.h"

#include <memory>

class CRtspClient;
class CRtspPusher;

class H264Source
{
public:
    H264Source(unsigned int framerate=25);
    ~H264Source();

    inline void setRtspClient(CRtspClient *client) { mRtspClient = client; }
    inline CRtspClient* getRtspClient(void) { return mRtspClient; }
    inline void setRtspPusher(CRtspPusher *pusher) { mRtspPusher = pusher; }
    inline CRtspPusher* getRtspPusher(void) { return mRtspPusher; }
    inline MediaType GetMediaType() { return media_type_; }
    inline unsigned int GetPayloadType() { return payload_; }
    inline unsigned int GetClockRate() { return clock_rate_; }
    inline void SetFramerate(unsigned int framerate) { framerate_ = framerate; }
    inline unsigned int GetFramerate() { return framerate_; }
    static unsigned int GetTimestamp();
    std::string GetMediaDescription(unsigned short port);
    const char* GetAttribute();
    bool HandleFrame(AVFrame *frame);

private:
    CRtspClient *mRtspClient;
    CRtspPusher *mRtspPusher;
    MediaType media_type_;
    unsigned int payload_;
    unsigned int clock_rate_;
    unsigned int framerate_;
};

#endif // H264SOURCE_H
